//
//  LYListTableViewCell.m
//  MusicMV
//
//  Created by dllo on 16/3/23.
//  Copyright © 2016年 Eternity. All rights reserved.
//

#import "LYListTableViewCell.h"

@interface LYListTableViewCell ()

@property (nonatomic, retain) UILabel *songLabel;
@property (nonatomic, retain) UILabel *singgerLabel;
//@property (nonatomic, retain) UILabel *numLabel;

@end
@implementation LYListTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createView];
    }
    return self;
}



- (void)createView {
    
    self.songLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_songLabel];
    
    self.singgerLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_singgerLabel];
    
    self.numLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_numLabel];
    
}


- (void)setModel:(LYDayMusicModel *)model {
    
    _model = model;
    
    _songLabel.text = model.name;
    
    _singgerLabel.text = model.singerName;
    _singgerLabel.font = [UIFont systemFontOfSize:15];
    _singgerLabel.textColor = [UIColor lightGrayColor];
    
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    
    self.numLabel.frame = CGRectMake(5 * wt, 15 * ht, 20 * wt, 20 * ht);
//    self.numLabel.backgroundColor = [UIColor redColor];
    
    
    // 文字的大小, 描述文字大小的信息
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:17], NSFontAttributeName, nil];
    // 通过文字大小获取文本的高度
    CGRect rect = [_model.name boundingRectWithSize:CGSizeMake(0, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil];
    self.songLabel.frame = CGRectMake(30 * wt, 5 * ht, rect.size.width, 40 * ht);
    
    
    NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont systemFontOfSize:15], NSFontAttributeName, nil];
    CGRect rect2 = [_model.singerName boundingRectWithSize:CGSizeMake(0, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:dic2 context:nil];
    self.singgerLabel.frame = CGRectMake(30 * wt + rect.size.width + 10 * wt, 10 * ht, rect2.size.width, 30 * ht);
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
